Skip to content

Potential fix for code scanning alert no. 13: Uncontrolled command line#21

Merged
Rootless-Ghost merged 1 commit intomainfrom
alert-autofix-13
Apr 26, 2026
Merged

Potential fix for code scanning alert no. 13: Uncontrolled command line#21
Rootless-Ghost merged 1 commit intomainfrom
alert-autofix-13

Conversation

@Rootless-Ghost
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/Rootless-Ghost/AtomicLoop/security/code-scanning/13

General fix: ensure any user-influenced command-line argument is strictly validated and canonicalized immediately before process execution, and fail closed if it does not match a narrow allowed format.

Best fix here (without changing functionality): in core/remote_executor.py, add a final defensive validation step right before building cmd_list, using a dedicated helper that only accepts canonical IPv4/IPv6 literals or RFC1123-style hostnames, then use that sanitized value in cmd_list. This keeps current behavior (valid hosts still work) while making the trust boundary explicit at sink proximity.

Changes needed:

  • File: core/remote_executor.py
  • Add a small helper function (near _HOST_RE) that validates a host string and returns a safe canonical value (or raises/returns failure).
  • Replace the direct target_host = normalized_host usage with safe_target_host = ... from that helper.
  • Use safe_target_host in both Windows and non-Windows cmd_list definitions and logging.
  • No new dependencies required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Rootless-Ghost Rootless-Ghost self-assigned this Apr 26, 2026
@Rootless-Ghost Rootless-Ghost marked this pull request as ready for review April 26, 2026 03:26
@Rootless-Ghost Rootless-Ghost merged commit ec459ca into main Apr 26, 2026
6 checks passed
@Rootless-Ghost Rootless-Ghost deleted the alert-autofix-13 branch April 26, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant